package com.sneakxy.cloudbase.platform.service;

import java.util.Collection;
import java.util.List;

import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.cloud.openfeign.SpringQueryMap;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;

import com.sneakxy.cloudbase.platform.bean.dto.DictDTO;
import com.sneakxy.cloudbase.platform.utils.web.DataGrid;
import com.sneakxy.cloudbase.platform.utils.web.PageSearch;
import com.sneakxy.cloudbase.platform.utils.web.Response;

@FeignClient(name="security-producer", path = "security/api/dict")
public interface DictClient {

	@PostMapping("datagrid")
	public Response<DataGrid<DictDTO>> datagrid(@SpringQueryMap PageSearch<String> search);
	
	@PostMapping("value/datagrid")
	public Response<DataGrid<DictDTO>> datagrid(
			@SpringQueryMap PageSearch<String> search,
			@RequestParam(name="parent_id") String parent_id);
	
	@PostMapping("add")
	public Response<DictDTO> add(@SpringQueryMap DictDTO dict);
	
	@PostMapping("edit")
	public Response<DictDTO> edit(@SpringQueryMap DictDTO dict);
	
	@PostMapping("value/add")
	public Response<DictDTO> valueAdd(@SpringQueryMap DictDTO dict);
	
	@PostMapping("value/edit")
	public Response<DictDTO> valueEdit(@SpringQueryMap DictDTO dict);
	
	@PostMapping("validate")
	public Response<Boolean> validate(@RequestParam(name="value") String value);
	
	@PostMapping("value/validate")
	public Response<Boolean> validate(
			@RequestParam(name="parent_id")
			String parent_id,
			@RequestParam(name="value")
			String value);
	
	@PostMapping("validateEdit")
	public Response<Boolean> validateEdit(
			@RequestParam(name="id")
			String id,
			@RequestParam(name="value")
			String value);
	
	@PostMapping("value/validateEdit")
	public Response<Boolean> validateEdit(
			@RequestParam(name="id")
			String id,
			@RequestParam(name="parent_id", required = false)
			String parent_id, 
			@RequestParam(name="value")
			String value);
	
	@PostMapping("remove")
	public Response<List<Integer>> remove(@RequestParam(name="ids") String[] ids);
	
	@PostMapping("values")
	public Response<DictDTO> values(
			@RequestParam(name="values", required = true)
			String[] values, 
			@RequestParam(name="children", required = true)
			boolean children);
	
	@PostMapping("one")
	public Response<DictDTO> one(
			@RequestParam(name="id", required = true)
			String id);
	
	@PostMapping("oneByType")
	public Response<DictDTO> oneByType(
			@RequestParam(name="parent_id", required = false)
			String parent_id,
			@RequestParam(name="value", required = true)
			String value, 
			@RequestParam(name="children", defaultValue="false", required = false)
			boolean children);
	
	@PostMapping("dicts")
	public Response<Collection<DictDTO>> dicts(
			@RequestParam(name="key", required = true)
			String key,
			@RequestParam(name="level", required = true)
			Integer level);
	
	@PostMapping("dict")
	public Response<DictDTO> dict(
			@RequestParam(name="key", required = true)
			String key,
			@RequestParam(name="level", required = true)
			Integer level,
			@RequestParam(name="value", required = true)
			String value);
	
}
